package com.sgb.kjwl.view.ui.adapter.search;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.SearchMaterialEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class SearchMaterialAdapter extends BaseRecycleAdapter<SearchMaterialEntity> {

    private TextView contentView;
    private TextView priceView;
    private TextView brand;

    public SearchMaterialAdapter(Context context, List<SearchMaterialEntity> datas) {
        super(context, R.layout.item_search_material, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SearchMaterialEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        brand = holder.getItem().findViewById(R.id.brand);
        priceView = holder.getItem().findViewById(R.id.price_view);
        contentView.setText(entity.getCityName() + entity.getAreaName());
        priceView.setText("￥ " + entity.getPrice() + "/" + entity.getUnit());

        if (TextUtils.isEmpty(entity.getBranName())) {
            brand.setVisibility(View.GONE);
        }
    }

}
